<?php
namespace App\Repositories\Main;

use App\Models\Main\MsgGroupModel;
use App\Repositories\BaseRepository;

class MsgGroupRepository extends BaseRepository
{
    protected $repository;

    public function __construct()
    {
        $this->repository = new MsgGroupModel();
    }

    public function getIndexList(){
        return $this->repository
            ->orderBy('id','asc')
            ->skip(0)
            ->take(10)
            ->get();
    }

    public function getGroupsByCid($cid){
        return $this->repository
            ->where('uid',$cid)
            ->orderBy('id','asc')
            ->get();
    }

    public function setAdd($data)
    {
        $data['created_at'] = time();
        return $this->repository->insertGetId($data);
    }

    public function getShowOne($id)
    {
        return $this->repository->where('id',$id)->first();
    }
}